import * as types from './mutation-types'
import dataCenter from '@/libs/dataCenter'

export const setCurrentTicketTab = ({ commit }, payload) => {
  commit(types.SET_CURRENT_TICKET_TAB, payload)
}

export const addTicketTab = ({ commit }, payload) => {
  commit(types.ADD_TICKET_TAB, payload)
}

export const removeTicketTab = ({ commit }, payload) => {
  commit(types.REMOVE_TICKET_TAB, payload)
}

export const clearTicketTab = ({ commit }) => {
  commit(types.CLEAR_TICKET_TAB)
}

export const initAllCities = ({ commit, state }) => {
  if (state.allCities.length === 0) {
    dataCenter.getCities(this, null, res => {
      commit(types.RECEIVE_ALL_CITIES, res)
    })
  }
}
